import React from "react";
import Child from "./child";

class Father extends React.Component {
  state = {
    number: 105,
    object: {
      number: 66,
      list: [0, 1, 2],
    },
  };
  handleNUm = () => {
    this.setState(
      {
        number: this.state.number + 10,
      },
      () => {
        console.log("num", this.state.number);
      }
    );
  };
  handleObj = () => {
    this.setState(
      {
        object: {
          ...this.state.object,
          number: this.state.object.number + 88,
          list: [this.state.object.number, 4, 5],
        },
      },
      () => {
        console.log("obj", this.state.object);
      }
    );
  };
  render() {
    return (
      <React.Fragment>
        <Child num={this.state.number} obj={this.state.object} />
        <button onClick={this.handleNUm}>图表NUMBER更改</button>
        <button onClick={this.handleObj}>图标的对象更改</button>
      </React.Fragment>
    );
  }
}

export default Father;
